<template>
	<view>
		<view class="between align-c tabs">
			<view class="tabs_item" v-for="(v,i) in navdatas" :key="i" @click="checkNav(v.type)">
				<view class="item-name" :class="{'act': status == v.type}" >{{ v.name }}</view>
				<view class="tabs_line" :class="{'tabs_line_act': status == v.type}"></view>
			</view>
		</view>
		
		<view class="place" />
		
		<view class="course" v-for="(v,i) in list" :key="i">
			<view class="course_top flex align-c">
				<view class="f1 flex align-c">
					<image v-if="v && v.user && v.user.avator" :src="$img(v.user.avator)" mode="aspectFill" class="course_top_img" />
					<image v-else src="/static/head.png" mode="aspectFill" class="course_top_img" />
					<view v-if="v && v.user && v.user.name">{{ v.user.name }}</view>
					<view v-else></view>
				</view>
				<view class="course_top_status" :class="{'red': v.status != 3}">{{ v.state }}</view>
			</view>
			<view class="course_content flex">
				<image v-if="v && v.course && v.course.cover" :src="$img(v.course.cover)" mode="aspectFill" class="course_content_img" />
				<view class="f1">
					<view class="fw-b" v-if="v && v.course && v.course.title">{{ v.course.title }}</view>
					<view class="course_content_label" v-if="v && v.course && v.course.start_at">时间：{{ v.course.start_at || '暂未设置时间' }}</view>
					<view class="course_content_label" v-if="v && v.course && v.course.location">位置：{{ v.course.location || '暂未更新位置' }}</view>
				</view>
			</view>
			<!-- <view class="course_bottom flex align-c" v-if="v.status != 2">
				<button class="btn" v-if="v.status == 2 || v.status == 3" @click="backMoney(v.id)">退款</button>
				<button class="btn" v-if="v.status == 3" @click="woffrecord(v.id)">核销记录</button>
				<button class="btn" v-if="v.status == 5" @click="toDetail(v.id)">查看详情</button>
			</view> -->
		</view>
		
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				navdatas: [
					{
						name: '已预约',
						type: 1
					}, {
						name: '未参加',
						type: 2,
					}, {
						name: '已完成',
						type: 4,
					},
				],
				status: 1,
				list: [],
				show: false,
				type: '',
				shop_id: '',
			}
		},
		onLoad(opt) {
			if(opt&& opt.type) {
				this.status = parseInt(opt.type)
			}
			this.getSystemInfo();
		},
		onShow() {
			this.shop_id = uni.getStorageSync('shopId');
			this.getOvertOrder();
		},
		methods: {
			getSystemInfo() {
				uni.getSystemInfo({
					success: (e) => {
						this.statusBar = e.statusBarHeight
					}
				})
			},
			checkNav(i){
				this.status = i;
				this.getOvertOrder();
			},
			async getOvertOrder() {
				let res = await this.$api.get('staff/course/date',{
					shop_id: this.shop_id,
					status: this.status,
					type: 1,
				});
				if(res.code == 200) {
					this.list = res.data;
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.tabs {
		background-color: #FFF;
		height: 44px;
		padding: 0 40rpx;
		position: fixed;
		left: 0;
		right: 0;
		top: 0;
		/* #ifdef H5 */
		top: 44px;
		/* #endif */
		z-index: 999;
		&_item {
			font-size: 27rpx;
			color: #B3B3B3;
		}
		.item-name {
			line-height: 30px;
		}
		.act {
			color: #F17816;
		}
		&_line {
			height: 7rpx;
			background: #ffffff;
			width: 53rpx;
			bottom: 2px;
			border-radius: 100px;
			transition-property: transform;
			transition-duration: 300ms;
			margin: 0 auto;
		}
		&_line_act {
			background-color: #F17816;
		}
	}
	.place {
		height: 44px;
	}
	.course {
		font-size: 27rpx;
		padding: 0 20rpx;
		background-color: #fff;
		margin: 20rpx 27rpx;
		border-radius: 20rpx;
		&_top {
			padding: 16rpx 0;
			border-bottom: 1rpx solid #F5F5F5;
			&_img {
				width: 47rpx;
				height: 47rpx;
				border-radius: 50%;
				margin-right: 16rpx;
			}
			&_check {
				width: 33rpx;
				height: 33rpx;
				margin-right: 16rpx;
				margin-right: 30rpx;
			}
			&_status {
				color: #B3B3B3;
			}
			.red {
				color: #F51818;
				font-weight: 500;
			}
		}
		&_content {
			padding: 20rpx 0;
			&_img {
				width: 160rpx;
				height: 160rpx;
				border-radius: 10rpx;
				margin-right: 20rpx;
			}
			&_label {
				font-size: 24rpx;
				color: #B3B3B3;
			}
			&_price {
				color: #F51818;
				text-align: right;
				.symbol {
					font-size: 27rpx;
				}
				.fw-b {
					font-size: 32rpx;
				}
				.util {
					font-size: 24rpx;
				}
			}
		}
		&_bottom {
			padding-top: 10rpx;
			padding-bottom: 30rpx;
			justify-content: flex-end;
			.btn {
				margin: 0;
				padding: 0;
				padding: 0 24rpx;
				font-size: 24rpx;
				font-family: PingFang SC;
				font-weight: 500;
				height: 47rpx;
				line-height: 47rpx;
				min-width: 93rpx;
				text-align: center;
				margin-left: 24rpx;
				background-color: #FFF;
			}
			.org_btn {
				background-color: #F17816;
				color: #fff;
			}
		}
	}
</style>